import type { FormItem } from "../../components/Form/index";
import type { TableConfigItem } from "../../components/Table/index";
import { Ref } from "vue";

//useBaseTable 入参
export interface UseTableParam {
  tableRef?: Ref<HTMLElement | null>;
  searchFormConifg: Ref<FormItem[]>;
  tableConifg: Ref<TableConfigItem[]>;
  getDataAPI(parma: object): Promise<Object>;
  addDataAPI?(parma: object): Promise<Object>;
  editDataAPI?(parma: object): Promise<Object>;
  delDataAPI?(id: number | string): Promise<Object>;
}

//useBaseTable 出参
export interface UseTableReturn {
  paginationProps: object;
  formDialogProps: Ref<DialogProps>;
  viewFormDialogProps: Ref<DialogProps>;
  tableData: Ref<object[]>;
  searchFormData: object;
  addHandle(): void;
  editHandle(formData: Record<string, unknown>, index?: number): void;
  getTableList(): void;
  searchHandle(): void;
  resetHandle(): void;
  submit(formData: Record<string, unknown>): void;
  delHandle(id: number | string): void;
  exportHandle(): void;
  handleSizeChange(val: number): void;
  handleCurrentChange(val: number): void;
  handleOpenView(formData: Record<string, unknown>): void;
}

// UseWirteTable出参
export interface UseWirteTableReturn
  extends Omit<UseTableReturn, "formDialogProps"> {
  editRowIndexArr: Ref<number[]>;
}

export interface DialogProps {
  dialogVisible: boolean;
  title: string;
  formData: object;
  type?: string;
}
